
import java.util.Scanner;

class LUA {

    static int[] media(int[] vet, int N, int M) {
        int[] media = new int[N - (M - 1)];
        for (int i = 0; i < media.length; i++) {
            int soma = 0;
            for (int j = i; j < (i + M); j++) {
                soma += vet[j];
            }
            media[i] = soma / M;
        }
        return media;
    }

    static int maior(int[] vet) {
        int X = vet[0];

        for (int i = 0; i < vet.length; i++) {
            if (X < vet[i]) {
                X = vet[i];
            }
        }
        return X;
    }

    static int menor(int[] vet) {
        int X = vet[0];
        for (int i = 0; i < vet.length; i++) {
            if (X > vet[i]) {
                X = vet[i];
            }
        }
        return X;
    }

    static Scanner entrada = new Scanner(System.in);
    
    public static void main(String[] args) {
        
        int N, M, n = 1;
        int[] vet;
        
        while ((N = entrada.nextInt()) != 0 & (M = entrada.nextInt()) != 0) {
            
            vet = new int[N];
            
            for (int i = 0; i < vet.length; i++) {
                vet[i] = entrada.nextInt();
            }
            
            System.out.println("Teste "+ n++);
            System.out.println(menor(media(vet, N, M))+" "+maior(media(vet, N, M)));
            System.out.println();
        }
    }
}
